﻿namespace WebApplication3
{
    using Microsoft.EntityFrameworkCore;
    using System.Diagnostics.CodeAnalysis;
    public class Order
    {
        public int Id { get; set; }
        public string Customer { get; set; }
        public int Sum { get; set; }
        public string ProductName { get; set; }
        public int Quantity { get; set; }
        public int Price { get; set; }
        public Order(int id, string customer, int sum, string productName, int quantity, int price)
        {
            Id = id;
            Customer = customer;
            Sum = sum;
            ProductName = productName;
            Quantity = quantity;
            Price = price;
        }
        public Order()
        {
            Id = 0;
            Customer = "小明";
            Sum = 0;
            ProductName = "productToBeCreate";
            Quantity = 0;
            Price = 0;
        }
        public override bool Equals(object? obj)
        {
            Order order = obj as Order;
            if (order.Id == Id
                && order.Customer == Customer
                && order.Sum == Sum
                && order.ProductName == ProductName
                && order.Quantity == Quantity
                && order.Price == Price)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
    public class OrderContext: DbContext
    {
        public DbSet<Order> orders { get; set; } = null!;
        public OrderContext(DbContextOptions<OrderContext> options): base(options)
        {
            this.Database.EnsureCreated();
        }
    }
}
